package com.java.system.common.entity.admin;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.java.system.common.validatedGroup.Add;
import com.java.system.common.validatedGroup.Modify;
import com.wordnik.swagger.annotations.ApiModel;
import com.wordnik.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;


/**
 * 应用表
 *
 * @author greatesky
 * @email greatesky@hotmail.com
 * @date 2019-09-21 16:45:38
 */
@ApiModel(value = "应用表")
@Table(name = "sys_client")
@Data
@Accessors(chain = true)
public class SysClient implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Null(message = "{add_id}", groups = {Add.class})
    @NotNull(message = "{modify_id}", groups = {Modify.class})
    private String id;
    /**
     * 客户端id  唯一不允许重复
     */
    @Column(name = "client_id")
    @ApiModelProperty(value = "客户端id")
    private String clientId;

    /**
     * 客户端密码
     */
    @JsonIgnore
    @Column(name = "client_secret")
    @ApiModelProperty(value = "客户端密码 ")
    private String clientSecret;

    /**
     * 允许访问的应用范围，多个应用之间用逗号隔开
     */
    @Column(name = "scope")
    @ApiModelProperty(value = "允许访问的应用范围，多个应用之间用逗号隔开")
    private String scope;

    /**
     * token过期时间(单位:秒)
     */
    @Column(name = "token_validity")
    @ApiModelProperty(value = "token过期时间(单位:秒)")
    private Integer tokenValidity;

    /**
     * token类型 0:不校验token ,1:需要校验token
     */
    @Column(name = "token_type")
    @ApiModelProperty(value = "token类型 0:不校验token 1：需要校验token")
    private Integer tokenType;
    /**
     * remark
     */
    @Column(name = "remark")
    @ApiModelProperty(value = "remark")
    private String remark;

    private String crtUser;

    private Date crtTime;

    private String crtName;

    private String crtHost;

    private String updUser;

    private Date updTime;

    private String updName;

    private String updHost;

    private Integer delFlag;

    /*public static SysClientInfo buildClientInfo(SysClient client) {
        if (client == null) {
            return new SysClientInfo();
        }
        SysClientInfo clientInfo = new SysClientInfo();
        BeanUtils.copyProperties(client, clientInfo);
        return clientInfo;
    }*/


}
